//  @author: nikyoudale
//  @link: https://github.com/nikyoudale/CocoaCryptoMac.git
//
//  CCMKeyLoader.h
//  RDelivery
//
//  Created by mellow on 2021/12/28.
//  Copyright (c) 2021 Tencent. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface RDeliveryRSAKeyLoader : NSObject

/** Load PKCS#1 PEM public key, i.e. -----BEGIN RSA PUBLIC KEY-----... */
+ (SecKeyRef)loadRSAPEMPublicKey:(NSString *)pemKey
                           error:(NSError **)error;
/** Load X.509 PEM public key, i.e. -----BEGIN PUBLIC KEY-----... */
+ (SecKeyRef)loadX509PEMPublicKey:(NSString *)pemKey
                            error:(NSError **)error;

/** Load PKCS#1 PEM private key, i.e. -----BEGIN RSA PRIVATE KEY-----... */
+ (SecKeyRef)loadRSAPEMPrivateKey:(NSString *)pemKey
                            error:(NSError **)error;
/** Load X.509 PEM private key, i.e. -----BEGIN PRIVATE KEY-----... */
+ (SecKeyRef)loadX509PEMPrivateKey:(NSString *)pemKey
                             error:(NSError **)error;

@end

#if TARGET_OS_IPHONE
@interface RDeliveryRSAKeyLoader (iPhone)

+ (SecKeyRef)secKeyRefWithData:(NSData *)srcData
                   isPublicKey:(BOOL)isPublicKey
                         error:(NSError **)error;

@end
#endif

#if TARGET_OS_OSX
@interface RDeliveryRSAKeyLoader (Mac)

+ (SecKeyRef)importPrivateKeyData:(NSData *)keyData
                   externalFormat:(SecExternalFormat)externalFormat
                            error:(NSError **)error;

+ (SecKeyRef)importPublicKeyData:(NSData *)keyData
                  externalFormat:(SecExternalFormat)externalFormat
                           error:(NSError **)error;

@end
#endif
